<HTML><HEAD><TITLE>[local domain(++Def), export domain(++Def)]</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Comparing and Sorting</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>local domain(++Def)</H1>
<H1>export domain(++Def)</H1>
Define a domain (a set of symbols mapped to natural numbers)
<DL>
<DT><EM>Def</EM></DT>
<DD>A structure with atomic arguments.
</DD>
</DL>
<H2>Description</H2>
<P>
	This defines a domain. A domain definition is a ground structure
	with atomic arguments. The structure's functor name is taken as
	the name of the domain. The domain name is used e.g. for declaring
	domain variables in lib(ic_symbolic).
	</P><P>
	The structure's arguments are the domain values. A domain value
	can be any atomic term (atom, string, number), but will usually
	be an atom. Domains are ordered, and the argument order in the
	defining structure implies the order of the domain values.
	The domain values are mapped to natural numbers, with the first
	argument being mapped to 1, the second to 2 and so on.
	</P><P>
	After having been defined, the mapping can be looked up via the
	primitives domain_index/3 and current_domain/3. Certain libraries
	(e.g. lib(ic_symbolic)) use the defined mapping internally.
	</P><P>
	Domain definitions can be local or exported. The domain values of
	all visible domain definitions within a module must be mutually
	exclusive, i.e. there must not be any ambiguity as to which domain
	a particular value belongs to. The system checks this condition
	whenever new domains are defined or imported.
    </P>
<H3>Modes and Determinism</H3><UL>
<LI>domain(++) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Def is not ground
<DT><EM>(5) type error </EM>
<DD>Def is neither variable nor structure
<DT><EM>(5) type error </EM>
<DD>A domain value is not atomic
<DT><EM>(6) out of range </EM>
<DD>A domain value is not unique in this module
<DT><EM>(87) attempt to redefine an existing local item </EM>
<DD>The domain name is already used locally
<DT><EM>(88) attempt to redefine an existing exported item </EM>
<DD>The domain name is already used and exported
<DT><EM>(89) attempt to redefine an already imported item </EM>
<DD>The domain name is already used by an imported domain
</DL>
<H2>Examples</H2>
<PRE>
    :- local domain(colour(red,green,blue)).

    :- export domain(vowel(a,e,i,o,u)).

    :- local domain(abc(a,b,c)).
    Domain value a not unique in module eclipse
    out of range in local domain(abc(a, b, c))
    Abort

    ?- current_domain(Name, DefModule, Def).
    Name = colour
    DefModule = eclipse
    Def = colour(red, green, blue)
    More (0.00s cpu) ? ;

    Name = vowel
    DefModule = eclipse
    Def = vowel(a, e, i, o, u)
    More (0.00s cpu) ? ;

    No (0.00s cpu)

    ?- domain_index(blue, Domain, Index).
    Domain = eclipse : colour
    Index = 3
    Yes (0.00s cpu)

    ?- domain_index(o, Domain, Index).
    Domain = eclipse : vowel
    Index = 4
    Yes (0.00s cpu)

    ?- domain_index(yellow, Domain, Index).
    No (0.00s cpu)
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/modules/local-1.html">local / 1</A>, <A HREF="../../kernel/modules/export-1.html">export / 1</A>, <A HREF="../../kernel/termcomp/current_domain-3.html">current_domain / 3</A>, <A HREF="../../kernel/termcomp/domain_index-3.html">domain_index / 3</A>, <A HREF="../../lib/ic_symbolic/index.html">library(ic_symbolic)</A>
</BODY></HTML>
